# -*- coding: utf-8 -*-
import mercurial.util as hgutil
from django.newforms import fields

def is_binary(data):
    return hgutil.binary(data)

def is_image(data):
    field = fields.ImageField()
    try:
        field.clean(dict(filename='dummy', content=data))
        return True
    except forms.ValidationError:
        return False
